package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Classinfo;
import cn.wolfcode.domain.Classinfo;
import cn.wolfcode.domain.Employee;
import cn.wolfcode.mapper.ClassinfoMapper;
import cn.wolfcode.service.IClassinfoService;
import cn.wolfcode.util.EmployeeQueryObject;
import cn.wolfcode.util.QueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
// 班级管理业务层
@Service
public class ClassinfoServiceImpl implements IClassinfoService {
    @Autowired
    private ClassinfoMapper classinfoMapper;

    @Transactional
    @Override
    public void insert(Classinfo classinfo) {
        classinfoMapper.insert(classinfo);
    }

    @Transactional
    @Override
    public void deleteById(Long id) {
        classinfoMapper.deleteByPrimaryKey(id);
    }

    @Transactional
    @Override
    public void update(Classinfo classinfo) {
        classinfoMapper.updateByPrimaryKey(classinfo);
    }

    @Override
    public Classinfo selectById(Long id) {
        return classinfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Classinfo> listAll() {
        return classinfoMapper.selectAll();
    }
    // 高查加分页
    @Override
    public PageInfo<Classinfo> query(QueryObject qo) {
        // 使用分页插件,传入当前页,每页显示数量
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Classinfo> classinfos = classinfoMapper.queryForList(qo);
        return new PageInfo<>(classinfos);
    }
}
